<?php 
/**
 * 北斗校车项目----地图展示界面
 * @author zsl
 * @com   沈阳微拓科技有限公司
 */
 // 初始化参数
 $param = "1";
 $data = Array();
 
 // 获取参数
 if(isset($_GET['id'])) {
	$param = $_GET['id'];
 }
 
?>

<!--
 地图展示界面
-->
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>校车位置</title>
    <style>
        body,html,#mapContainer{
            width: 100%;
			height: 100%;
			overflow: hidden;
			margin:0;
			font-family:"微软雅黑";
        }
    </style>
   
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=z1RBwgbA3pUnFAbP5UVhtWX1bN1y9bsq"></script>
	<script src="./js/jquery.1.7.1.min.js"></script>
    <script>
	var map;
	var marker;
	var nums;
	nums = "";
        function init() {
			map = new BMap.Map("mapContainer");
			map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
			map.centerAndZoom(new BMap.Point(123.247583, 41.507051), 16);  // 初始化地图,设置中心点坐标和地图级别
            //map.setCurrentCity("沈阳"); 
			marker = new BMap.Marker(new BMap.Point(123.247583, 41.507051)); // 创建点			
            map.addOverlay(marker);            //增加点
			setInterval("aa()",3000);
        }
		
		function aa() {
			$.ajax({
				url:"./returndata.php",
				dataType:"json",
				data:{
					num:nums,
				},
				type:"GET",
				success:function(data) {					
					var pos = new BMap.Point(data.x, data.y);
					var discant = map.getDistance(map.getCenter(),pos).toFixed(2);
					if(discant / 200 > 1) {
						map.setCenter(pos);
					}
					marker.setPosition(pos);
					
				},
				error:function(data) {
					alert("服务器压力过大，请稍后访问");
				}
			});	
		}
		
		
    </script>
</head>
<body onload="init()">
    <div id="mapContainer" ></div>
    
</body>
</html>